Aims

In this tutorial, we will learn:

The mariage between plotly and ggplot

In rethomics, the graphs are generated as ggplot objects. These can be exported as pdfs which is great for publication-quality graphs. However, sometimes, we want some degree of interactiveness with the figures (i.e. zoom, exclude some data, look up the value of the points…). The packages plotly can take pretty much any ggplot object and make it interactive.

First, lets make an ethogram as a static figure see here:

data(sleep_sexual_dimorphism)
dt <- sleep_sexual_dimorphism
pl <- ethogramPlot(moving, dt, sex, error_bar="sem")
pl

This pl object is a static figure, so is is just displayed as an image.

We can load plotly to display this plot as an interactive widget:

install.packages("plotly")
library("plotly")

Now by just using ggplotly() function, we can do:

ggplotly(pl)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`

A few useful thing we can do here:

For more info, have a look at the plotly package itself.